﻿using System;
namespace Producers.Kis.Xtee.Riik.Ee.Producer.Kis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="MKMConfirmation", Namespace="http://producers.kis.xtee.riik.ee/producer/kis", Target=typeof(MKMConfirmation))]
    public class MKMConfirmationSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMKMConfirmation clazz;
        
        public MKMConfirmationSerializer(IMKMConfirmation clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Identificator");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Identificator))).ToString());
            Writer.WriteEndElement();
            for (int x = 0; ((clazz.Comment != null) 
                        && (x < clazz.Comment.Count)); x = (x + 1)) {
                if (clazz.Comment[x]!=null) {
                    Writer.WriteStartElement("Comment");
                    Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                    Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Comment[x]))).ToString());
                    Writer.WriteEndElement();
                }
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Identificator") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>MKMConfirmation>Identificator");
                }
                clazz.Identificator = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("Identificator")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>MKMConfirmation>Identificator", Reader.LocalName);
            }
            if (Reader.LocalName=="Comment") {
                clazz.Comment = new System.Collections.Generic.List<System.String>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "Comment")); ) {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>MKMConfirmation>Comment");
                    }
                    clazz.Comment.Add(new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Comment")).Value);
                }
            }
        }
    }
}
